<<<<<<< HEAD
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Mailer
{

    var $mail;

    public function __construct()
    {
        require_once('PHPMailer-master/class.phpmailer.php');

        // the true param means it will throw exceptions on errors, which we need to catch
        $this->mail = new PHPMailer(true);

        $this->mail->IsSMTP(); // telling the class to use SMTP

        $this->mail->CharSet = "utf-8";                  // 一定要設定 CharSet 才能正確處理中文
        $this->mail->SMTPDebug = 0;                     // enables SMTP debug information
        $this->mail->SMTPAuth = true;                  // enable SMTP authentication
        $this->mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
        $this->mail->Host = "";      // sets GMAIL as the SMTP server
        $this->mail->Port = "";                   // set the SMTP port for the GMAIL server
        $this->mail->Username = "";
        $this->mail->Password = "";

    }

    public function sendmail($to, $to_name, $subject, $body)
    {
        try {
            $this->mail->AddAddress($to, $to_name);
            $this->mail->SetFrom($this->mail->Username, $to_name);
            $this->mail->Subject = $subject;
            $this->mail->Body = $body;
            $this->mail->IsHTML(true);
            $this->mail->Send();
            return true;

        } catch (phpmailerException $e) {
            echo $e->errorMessage(); //Pretty error messages from PHPMailer
            return false;
        } catch (Exception $e) {
            echo $e->getMessage(); //Boring error messages from anything else!
            return false;
        }
    }
}

/* End of file mailer.php */
=======
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Mailer
{

    var $mail;

    public function __construct()
    {
        require_once('PHPMailer-master/class.phpmailer.php');

        // the true param means it will throw exceptions on errors, which we need to catch
        $this->mail = new PHPMailer(true);

        $this->mail->IsSMTP(); // telling the class to use SMTP

        $this->mail->CharSet = "utf-8";                  // 一定要設定 CharSet 才能正確處理中文
        $this->mail->SMTPDebug = 0;                     // enables SMTP debug information
        $this->mail->SMTPAuth = true;                  // enable SMTP authentication
        $this->mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
        $this->mail->Host = "";      // sets GMAIL as the SMTP server
        $this->mail->Port = "";                   // set the SMTP port for the GMAIL server
        $this->mail->Username = "";
        $this->mail->Password = "";

    }

    public function sendmail($to, $to_name, $subject, $body)
    {
        try {
            $this->mail->AddAddress($to, $to_name);
            $this->mail->SetFrom($this->mail->Username, $to_name);
            $this->mail->Subject = $subject;
            $this->mail->Body = $body;
            $this->mail->IsHTML(true);
            $this->mail->Send();
            return true;

        } catch (phpmailerException $e) {
            echo $e->errorMessage(); //Pretty error messages from PHPMailer
            return false;
        } catch (Exception $e) {
            echo $e->getMessage(); //Boring error messages from anything else!
            return false;
        }
    }
}

/* End of file mailer.php */
>>>>>>> 354f4b2fb2288b3c61dba6a59b3136f80f4b6909
 